<template>
  <div>
    <div style="display:flex;flex-direction:row-reverse;margin-top:10px">
      <el-button :disabled="submitLoading" size="mini" type="primary" @click="submitForm(0)">保存</el-button>
      <el-button style="margin-right:20px" :disabled="submitLoading" size="mini" type="primary" @click="submitForm(1)">提交</el-button>
    </div>
    <div v-loading="dataLoading">
      <base-info :base-info="detailData" />
      <!-- <drawing-info :base-info="detailData" /> -->
      <distribute :base-info="detailData" />
      <drawing-edit ref="drawingEdit" :base-info="detailData" />
    </div>
  </div>
</template>
<script>
import BackPageMixin from '@/mixins/backPage'
import { queryDetail, submitFacadeBack } from '@/api/autoDesignTask'
import baseInfo from './component/BaseInfo.vue'
import drawingInfo from './component/DrawingInfo.vue'
import distribute from './component/distributeInfo.vue'
import drawingEdit from './component/DrawingEdit.vue'
export default {
  name: 'FacadeBack',
  components: { baseInfo, drawingInfo, distribute, drawingEdit },
  mixins: [BackPageMixin],
  props: {
  },
  data() {
    return {
      id: '',
      detailData: {},
      designer: [],
      shopAttachmentDTOList: [],
      submitLoading: false,
      dataLoading: false
    }
  },
  watch: {
  },
  async  created() {
    // const { SLM_BUSINESS_TYPE } = await getDictByPatchType(['SLM_BUSINESS_TYPE'])
    // this.businessTypeList = SLM_BUSINESS_TYPE
    this.id = this.$route.query.id
    if (this.id) {
      this.dataLoading = true
      queryDetail(this.id).then(res => {
        if (res.success) {
          this.detailData = res.data
          this.dataLoading = false
        }
      })
    }
    this.dataLoading = false
  },
  mounted() {
  },
  methods: {
    goBack() {
      this.$store.dispatch('views/goBack')
    },
    async submitForm(type) {
      const submitData = await this.$refs['drawingEdit'].submitData()
      if (!submitData) return
      if (this.submitLoading) return
      this.submitLoading = true
      submitFacadeBack(submitData, type).then(res => {
        if (res.success) {
          this.$message.success('操作成功')
          this.goBack()
          this.submitLoading = false
        }
      }).catch(() => {
        this.submitLoading = false
      })
    }

  }
}
</script>
<style lang="scss" scoped>
/deep/ .el-breadcrumb__inner{
    color: $qup-color-primary;
  }
</style>
